import {fromJS} from 'immutable'
import {HANDLER_CHANGE_USERNAME,HANDLER_CHANGE_PASSWORD,RECEIVE_LOGIN_DATA} from '../../../store/actionTypes'
//使用immutable来防止state数据被改变，
const defaultState = fromJS({
    username:'',
    password:'',
    success:false
});
export default (state = defaultState,action) =>{
   if(action.type == HANDLER_CHANGE_USERNAME ){
       return state.set('username',action.data);
   }
   if(action.type == HANDLER_CHANGE_PASSWORD ){
    return state.set('password',action.data);
   }
   if(action.type == RECEIVE_LOGIN_DATA){
    return state.set('success',action.success);
   }
    return state;
}
